<template>
    <div>
        <group>
            <cell title="账号" :value="username">
                <i slot="icon" class="icon iconfont icon-zhaopin1" style="color: #ff6600;"></i>
            </cell>
        </group>
        <div style="padding:0 10px">
            <group>
                <x-button v-if="isLogin" type="primary" @click.native="dologout">退出登录</x-button>
                <x-button v-if="!isLogin" type="primary" @click.native="onback">返回</x-button>
            </group>
            <!-- <group>
                <x-button type="primary" @click.native="doClear">清除文件</x-button>
            </group> -->
        </div>
        <!-- <div style="bottom:10px;position: absolute;width: 100%;text-align: center;">
            <p class="footer__links" style="padding:0;margin: 0;">
                杭州知达
            </p>
            <p class="footer__text" style="margin-top: 2px;">Copyright © 2014-2017 7dtime.com</p>
        </div> -->
    </div>
</template>
<script>
import {
    Cell,
    XTextarea,
    XInput,
    Group,
    XButton
} from 'vux'
import {
    mapState,
    mapActions
} from 'vuex'

import api from '../api'
import { help } from "./mixinApp";

export default {
    components: {
        Cell,
        XTextarea,
        XInput,
        Group,
        XButton
    },
    mixins: [help],    
    mounted: function() {
        // this.getData();
    },
    updated: function() {

    },
    methods: {
        dologout() {
            console.log(this.isLogin);
            api.logout().then(data => {
                if(data.errno !=0) return this.$vux.toast.show({text: data.errmsg ,type: 'warn'});
				
				this.login(false);
				this.user({});
				this.$router.back(-1); //this.go("m_mine");
				window.localStorage.removeItem('token');
				this.$store.commit({ type: "z39/reset" });
				this.parseDefault();                
            })
        },
        onback(){
            this.$router.back(-1);
        },
        doClear(){
            try{
                cleanHistory();   //清除本地所有录音文件.
            }catch(e){console.log("dcloud not ready")}
        },
        ...mapActions([
            'user', 'login'
        ])
    },
    computed: {
        ...mapState({
            isLogin: state => state.vux.isLogin,
            username: state => state.vux.username,
        })
    },
    data() {
        return {

        }
    }
}
</script>
<style scoped>
</style>
